package com.atguigu.staservice.controller;


import com.atguigu.common.R;
import com.atguigu.staservice.entity.StatisticsDaily;
import com.atguigu.staservice.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-04-25
 */
@RestController
@RequestMapping("/staservice/sta")
//@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService staService;

    //1 生成统计数据
    @PostMapping("createStaData/{day}")
    public R createStaData(@PathVariable String day) {
        staService.createSta(day);
        return R.ok();
    }

    //图表显示返回统计数据
    @GetMapping("showCharts/{type}/{begin}/{end}")
    public R showCharts(@PathVariable String type,
                        @PathVariable String begin,
                        @PathVariable String end) {
        Map<String,Object> map = staService.getShowData(type,begin,end);
        return R.ok().data(map);
    }
}

